package com.jiangtai.training.ui.task

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.jiangtai.training.R
import com.jiangtai.training.bean.TaskBean
import com.jiangtai.training.constant.Constant
import com.jiangtai.training.util.DateUtil

/**
 * Created by heCunCun on 2021/3/8
 */
class TaskAllAdapter:BaseQuickAdapter<TaskBean,BaseViewHolder>(R.layout.item_task_list) {
    override fun convert(helper: BaseViewHolder, item: TaskBean?) {
        item?:return
        helper.setText(R.id.tv_task_name,item.taskName)
        helper.setText(R.id.tv_id,item.taskId)
        helper.setText(R.id.tv_start_time, DateUtil.changeLongToDate(item.startTime))
        helper.setText(R.id.tv_end_time, DateUtil.changeLongToDate(item.endTime))
        val ivTaskState =  helper.getView<ImageView>(R.id.iv_task_state)
        when(item.state){
            Constant.STATE_PRE->{
                helper.setText(R.id.tv_task_state,"未开始")
                ivTaskState.setImageResource(R.mipmap.ic_state_pre)
            }
            Constant.STATE_RUNNING->{
                helper.setText(R.id.tv_task_state,"进行中")
                ivTaskState.setImageResource(R.mipmap.ic_state_running)
            }
            Constant.STATE_FINISHED->{
                helper.setText(R.id.tv_task_state,"已结束")
                ivTaskState.setImageResource(R.mipmap.ic_state_finish)
            }
        }

    }
}